Creating and using a global-object
How to create a global-object:
-
Select a folder in the project in which you want to create the global-object.
In the application navigator: The best practice is to create new global-objects below Application so that the global variables in these created global objects are displayed in a structured way. -
In menu File or from the context menu of the folder, select New and the command Global-Object.
-
In the dialog, enter a name under File Name.
If possible, do not enter invalid characters (e.g. umlauts, blanks, the character –, numbers at the start) because the file name is automatically used as global-object-name and this name must be a valid →IEC-identifier. But if you need such invalid characters in the file name, delete or replace the invalid characters in Global-Object-Name before you click Finish.
It is possible to change the global-object-name at any time later. -
Afterwards click Finish.
Result:-
The global-object (with icon ) is displayed in the views with projects and resources.
-
The global-object is opened in the →graphical editor.
-
-
Create or edit the content, e.g. the →global variables. Details: See"Actions within the global-variables-editor".
-
In order to use the global variables within the application, assign the global-object to an ST-→program or a →resource or →configuration. Best practice is to drag the global-object within the application navigator onto the corresponding object:
-
Make the application navigator visible.
-
Point to the global-object that is displayed below the folder Application (or a subfolder of it).
-
Press and hold the primary mouse button and drag the global-object onto the program type (usually displayed below the folder Application) or onto the resource or configuration that is displayed within the application navigator.
-
Release the primary mouse button.
Result: The ST-program or the PLC-object (containing the resource or configuration) is enhanced by the necessary reference. This reference is anINCLUDE_GLOBALS
directive (see "Declaration of global variables in global-object and its usage in ST", if you need more information on this directive). If you assigned the global-object to a resource or configuration, this global-object is also displayed in the folder Configuration-Global Variables or Resource-Global Variables.
-
Good to know |
---|
In order to unassign the global-object from a resource or configuration, proceed as follows:
|